home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 7 / Amiga Format AFCD07 (Dec 1996, Issue 91).iso / serious / shareware / comms / internet / html-related / aha! / arexx / aha!.ttx next >
Text File  |  1996-09-14  |  7KB  |  239 lines

  1. /* Arexx macro to put HTML tag, that is passed from the command line as argument, around
  2.    currently selected block or current line (if no block is selected)
  3.  
  4.       Written on 08/17/96 by Oleg Moskalensky
  5.    Last Modified on 09/15/96 by Oleg Moskalensky
  6.    Copyright © 1996 - Productive Computer Systems
  7.               ALL RIGHTS RESERVED
  8. */
  9.  
  10. /* trace ?R */
  11.  
  12. OPTIONS RESULTS
  13.  
  14. ARG Tag
  15.  
  16. address "TURBOTEXT0"
  17.  
  18. StartTag = "<" || Tag || ">"
  19. EndTag = "</" || Tag || ">"
  20.  
  21. if Tag = "BR" then 
  22.     do
  23.         insert "<BR>"
  24.         return
  25.     end
  26.  
  27. if Tag = "HR" then
  28.     do
  29.       EndTag = ""
  30.       'RequestStr PROMPT "Enter Width" "100%"'
  31.       Width = RESULT
  32.       if RC = 0 & Width ~= "100%" then StartTag = "<HR WIDTH=" || Width || ">"
  33.    end
  34.  
  35. if Tag = "P" then
  36.    do
  37.       'RequestChoice "Paragraph" "Select paragraph alignment" "Left|Center|Right|Cancel"'
  38.       Alignment = RESULT
  39.       select
  40.          when Alignment = 1 then StartTag = "<P ALIGN=LEFT>"
  41.          when Alignment = 2 then StartTag = "<P ALIGN=CENTER>"
  42.          when Alignment = 3 then StartTag = "<P ALIGN=RIGHT>"
  43.          otherwise
  44.             do
  45.                'ActivateWindow'
  46.                'MarkBlk'
  47.                RETURN
  48.             end
  49.       end
  50.    end
  51.  
  52. if Tag = "IMG" then
  53.    do
  54.       'RequestFile PROMPT "Please select an IMAGE file"'
  55.       if RC = 0 then
  56.          do
  57.             Imagename = RESULT
  58.             text '<IMG SRC="' || Imagename || '"'
  59.  
  60.             'RequestChoice "Image Alignment" "Select ALIGNMENT option" "TOP|MIDDLE|BOTTOM|None"'
  61.             Alignment = RESULT
  62.             select
  63.                when Alignment = 1 then 'text " ALIGN=TOP"'
  64.                when Alignment = 2 then 'text " ALIGN=MIDDLE"'
  65.                when Alignment = 3 then 'text " ALIGN=BOTTOM"'
  66.                otherwise NOP
  67.             end
  68.  
  69.             text '>'
  70.             'ActivateWindow'
  71.             RETURN
  72.          end
  73.    end
  74.  
  75. if Tag = "MAIL" then
  76.    do
  77.       'RequestStr PROMPT "Enter a valid e-mail address" "pcs@accessone.com"'
  78.       email = RESULT
  79.       if RC = 0 then
  80.          do
  81.            StartTag = '<A HREF="mailto:' || email || '">'
  82.            EndTag = '</A>'
  83.          end
  84.        else
  85.          do
  86.             'ActivateWindow'
  87.              RETURN
  88.          end
  89.    end
  90.  
  91. if Tag = "FONTSIZE" then
  92.    do
  93.       'RequestChoice "Font Size" "Select FONT adjustment amount" "-3|-2|-1|+1|+2|+3|Cancel"'
  94.       FontVariation = RESULT
  95.       select
  96.          when FontVariation = 1 then StartTag = "<FONT SIZE=-3>"
  97.          when FontVariation = 2 then StartTag = "<FONT SIZE=-2>"
  98.          when FontVariation = 3 then StartTag = "<FONT SIZE=-1>"
  99.          when FontVariation = 4 then StartTag = "<FONT SIZE=+1>"
  100.          when FontVariation = 5 then StartTag = "<FONT SIZE=+2>"
  101.          when FontVariation = 6 then StartTag = "<FONT SIZE=+3>"
  102.          otherwise
  103.             do
  104.                'ActivateWindow'
  105.                RETURN
  106.             end
  107.       end
  108.       EndTag = "</FONT>"
  109.    end
  110.  
  111. if Tag = "FONTCOLOR" then
  112.    do
  113.       'RequestChoice "Font Color" "Select predefined or your own color" "Black|White|Red|Green|Blue|CHOOSE|Cancel"'
  114.       FontColor = RESULT
  115.       select
  116.          when FontColor = 1 then StartTag = '<FONT COLOR="#000000">'
  117.          when FontColor = 2 then StartTag = '<FONT COLOR="#FFFFFF">'
  118.          when FontColor = 3 then StartTag = '<FONT COLOR="#FF0000">'
  119.          when FontColor = 4 then StartTag = '<FONT COLOR="#00FF00">'
  120.          when FontColor = 5 then StartTag = '<FONT COLOR="#0000FF">'
  121.          when FontColor = 6 then
  122.             do
  123.                 'RequestStr PROMPT "Enter color as a 6-digit RGB number (default: yellow)" "FFFF00"'
  124.                 Color = RESULT
  125.                 if RC ~= 0 then
  126.                     do
  127.                         'ActivateWindow'
  128.                         'MarkBlk'
  129.                         RETURN
  130.                     end
  131.                 else StartTag = '<FONT COLOR="#' || Color || '">'
  132.             end
  133.          otherwise
  134.             do
  135.                'ActivateWindow'
  136.                'MarkBlk'
  137.                RETURN
  138.             end
  139.       end
  140.       EndTag = "</FONT>"
  141.    end
  142.  
  143. if Tag = "UL" then
  144.     do
  145.         'RequestChoice "Non-numbered List" "Select character style" "Bullet|Square|Circle|Cancel"'
  146.         Style = RESULT
  147.         select
  148.             when Style = 1 then ListType = ""
  149.             when Style = 2 then ListType = "TYPE=SQUARE"
  150.             when Style = 3 then ListType = "TYPE=CIRCLE"
  151.             otherwise
  152.                 do
  153.                     'ActivateWindow'
  154.                     'MarkBlk'
  155.                     RETURN
  156.                 end
  157.         end
  158.     end
  159.  
  160. if Tag = "OL" then
  161.     do
  162.         'RequestChoice "Numbered List" "Select numbering style" "1|I|A|a|Cancel"'
  163.         Style = RESULT
  164.         select
  165.             when Style = 1 then ListType = "TYPE=1"
  166.             when Style = 2 then ListType = "TYPE=I"
  167.             when Style = 3 then ListType = "TYPE=A"
  168.             when Style = 4 then ListType = "TYPE=a"
  169.             otherwise
  170.                 do
  171.                     'ActivateWindow'
  172.                     'MarkBlk'
  173.                     RETURN
  174.                 end
  175.         end
  176.     end
  177.  
  178. do
  179.    getblkinfo
  180.    parse var RESULT SelectedBlock dummy BeginRow BeginCol
  181.    if SelectedBlock = "ON" then
  182.       do
  183.          getcursorpos
  184.          parse var RESULT EndRow EndCol dummy
  185.  
  186.          if (Tag = "UL" | Tag = "OL") then
  187.             do
  188.                 move BeginRow 1
  189.                 insert "<" || Tag || " " || ListType || ">"
  190.                 'InsertLine'
  191.                 BeginRow = BeginRow + 1
  192.                 EndRow = EndRow + 1
  193.                 call InsertLI
  194.                 move EndRow 1
  195.                 if (EndCol = 1) then
  196.                         do
  197.                         text "</" || Tag || ">"
  198.                         insertline
  199.                     end
  200.                 else
  201.                     do
  202.                         moveeol
  203.                         insertline
  204.                         text "</" || Tag || ">"
  205.                     end
  206.                 'MarkBlk'
  207.                 'ActivateWindow'
  208.                 RETURN
  209.             end
  210.  
  211.             move BeginRow BeginCol
  212.          insert StartTag
  213.          if BeginRow = EndRow then
  214.             move EndRow (EndCol + length(StartTag))
  215.          else
  216.             move EndRow EndCol
  217.          insert EndTag
  218.          'MarkBlk'
  219.          'ActivateWindow'
  220.       end
  221.    else
  222.       do
  223.          movesol
  224.          text StartTag
  225.          moveeol
  226.          text EndTag
  227.          'ActivateWindow'
  228.       end
  229. end
  230.  
  231. exit 0
  232.  
  233. InsertLI:
  234.     do Row = BeginRow to (EndRow - ((EndCol=1) * 1))
  235.         move Row 1
  236.         text "<LI>"
  237.     end
  238.  
  239. RETURN